package com.some;

import java.util.*;

public class RedBook_01 {
    public static int getNum(Set<Integer> nums) {
        int res = 1;
        int len = nums.size();
        if (len < 1) {
            return 0;
        }
        List<Integer> collect = new ArrayList<>(nums);
        Collections.sort(collect);
        int compareNum = collect.get(0);
        for (int i = 1; i < len; i++) {
            if (compareNum == collect.get(i) - 1) {
                res++;
                compareNum = collect.get(i);

            } else {
                break;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int length = sc.nextInt();
        Set<Integer> set = new HashSet();
        for (int i = 0; i < length; i++) {
            set.add(sc.nextInt());
        }
        System.out.println(getNum(set));
    }
}
